Paul's JavaScript Examples    
 
Getting the current date and time

A very simple script that returns the current date and time. In the example it is returned in a requester, it can also be used inside a document with the document.write method. As shown at the top of this page.

Example

Usage

<input type="button" value=" Tell me the date and time! "  onClick="Get_Date()">

Source

<SCRIPT LANGUAGE="javascript">
<!--
function Get_Date()
{
   today = new Date()
   alert('The date is now:\n' + today)
}

today = new Date()
document.write('Page loaded at ' + today)
// -->
</SCRIPT>